home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / gamesa / frmgame1.frm (.txt) < prev    next >
Visual Basic Form  |  1999-08-01  |  5KB  |  221 lines

  1. VERSION 5.00
  2. Begin VB.Form frmGame1 
  3.    AutoRedraw      =   -1  'True
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "Buckets"
  6.    ClientHeight    =   6120
  7.    ClientLeft      =   45
  8.    ClientTop       =   330
  9.    ClientWidth     =   8910
  10.    BeginProperty Font 
  11.       Name            =   "MS Sans Serif"
  12.       Size            =   13.5
  13.       Charset         =   0
  14.       Weight          =   700
  15.       Underline       =   0   'False
  16.       Italic          =   0   'False
  17.       Strikethrough   =   0   'False
  18.    EndProperty
  19.    Icon            =   "frmGame1.frx":0000
  20.    KeyPreview      =   -1  'True
  21.    LinkTopic       =   "Form1"
  22.    MaxButton       =   0   'False
  23.    MinButton       =   0   'False
  24.    ScaleHeight     =   650
  25.    ScaleMode       =   0  'User
  26.    ScaleWidth      =   900
  27.    ShowInTaskbar   =   0   'False
  28.    StartUpPosition =   2  'CenterScreen
  29.    Begin VB.Timer Timer1 
  30.       Interval        =   50
  31.       Left            =   3885
  32.       Top             =   2820
  33.    End
  34. Attribute VB_Name = "frmGame1"
  35. Attribute VB_GlobalNameSpace = False
  36. Attribute VB_Creatable = False
  37. Attribute VB_PredeclaredId = True
  38. Attribute VB_Exposed = False
  39. Option Explicit
  40. Dim oper As Integer
  41. Dim a As Integer
  42. Dim ctr As Integer
  43. Dim b As Integer
  44. Dim c As Integer
  45. Dim res As Integer
  46. Dim sym As String
  47. Dim buc As Integer
  48. Dim bucold As Integer
  49. Dim lim(1 To 4) As Integer
  50. Dim check(1 To 4) As Integer
  51. Dim white As Long
  52. Dim black As Long
  53. Dim red As Long
  54. Dim green As Long
  55. Dim blue As Long
  56. Dim yellow As Long
  57. Dim x1 As Integer
  58. Dim x2 As Integer
  59. Dim y1 As Integer
  60. Dim y2 As Integer
  61. Dim x3 As Integer
  62. Dim y3 As Integer
  63. Dim buf As String
  64. Dim score As Integer
  65. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  66. If KeyCode = 27 Then
  67. Unload frmGame1
  68. frmMain.Show 1
  69. End If
  70. buf = buf + Chr(KeyCode)
  71. If Val(buf) = res Then
  72. c = 0
  73. score = score + 50
  74. ForeColor = black
  75. FillStyle = 0
  76. x1 = 35 + buc * 220
  77. y1 = 30 * (ctr - 1)
  78. x2 = 35 + buc * 215 + 170
  79. y2 = 30 * (ctr - 1) + 30
  80. x3 = 35 + buc * 220
  81. y3 = 30 * ctr
  82. Line (x1, y1)-(x2, y2), , B
  83. Line (375, 5)-(700, 35), , B
  84. ForeColor = white
  85. FillStyle = 1
  86. PSet (375, 5), black
  87. ForeColor = yellow
  88. Print "Score : "; score
  89. ForeColor = white
  90. ctr = 3
  91. buf = ""
  92. End If
  93. End Sub
  94. Private Sub Form_Load()
  95. c = 0
  96. ctr = 3
  97. lim(1) = 20
  98. lim(2) = 20
  99. lim(3) = 20
  100. lim(4) = 20
  101. check(1) = 0
  102. check(2) = 0
  103. check(3) = 0
  104. check(4) = 0
  105. If Speed = 1 Then Timer1.Interval = 300
  106. If Speed = 2 Then Timer1.Interval = 250
  107. If Speed = 3 Then Timer1.Interval = 200
  108. If Speed = 4 Then Timer1.Interval = 150
  109. If Speed = 5 Then Timer1.Interval = 100
  110. white = RGB(255, 255, 255)
  111. black = RGB(0, 0, 0)
  112. red = RGB(255, 0, 0)
  113. green = RGB(0, 255, 0)
  114. blue = RGB(0, 0, 255)
  115. yellow = RGB(255, 255, 0)
  116. DrawWidth = 4
  117. ForeColor = green
  118. BackColor = black
  119. FillColor = black
  120. FillStyle = 1
  121. Line (20, 500)-(20, 645)
  122. Line (20, 645)-(220, 645)
  123. Line (220, 645)-(220, 500)
  124. Line (240, 500)-(240, 645)
  125. Line (240, 645)-(440, 645)
  126. Line (440, 645)-(440, 500)
  127. Line (460, 500)-(460, 645)
  128. Line (460, 645)-(660, 645)
  129. Line (660, 645)-(660, 500)
  130. Line (680, 500)-(680, 645)
  131. Line (680, 645)-(880, 645)
  132. Line (880, 645)-(880, 500)
  133. ForeColor = yellow
  134. PSet (375, 5), black
  135. Print "Score : "; score
  136. ForeColor = blue
  137. Line (0, 42)-(900, 42)
  138. ForeColor = white
  139. End Sub
  140. Private Sub Timer1_Timer()
  141. If c = 0 Then
  142. goback:
  143. If check(1) = 4 And check(2) = 4 And check(3) = 4 And check(4) = 4 Then
  144. MsgBox "Game End" + vbCrLf + "Your Score : " + Str(score)
  145. Unload frmGame1
  146. frmMain.Show 1
  147. End If
  148. If Choice = 1 Then oper = 1
  149. If Choice = 2 Then oper = 2
  150. If Choice = 3 Then oper = 3
  151. If Choice = 4 Then oper = 4
  152. If Choice = 5 Then
  153. Randomize
  154. oper = Int((4 * Rnd) + 1)
  155. End If
  156. buc = Int(4 * Rnd)
  157. If check(1) + check(2) + check(3) + check(4) >= 12 Then GoTo bg2
  158. If buc = bucold Then GoTo bg1
  159. If check(buc + 1) = 4 Then GoTo goback
  160. bucold = buc
  161. If oper = 1 Then
  162. sym = "+"
  163. a = Int((9 * Rnd) + 1)
  164. b = Int((9 * Rnd) + 1)
  165. If a = b Then GoTo gb1
  166. res = a + b
  167. End If
  168. If oper = 2 Then
  169. sym = "-"
  170. a = Int((9 * Rnd) + 1)
  171. b = Int((9 * Rnd) + 1)
  172. If a = b Then GoTo gb2
  173. res = a - b
  174. If a - b < 0 Then GoTo gb1
  175. End If
  176. If oper = 3 Then
  177. sym = "x"
  178. a = Int((9 * Rnd) + 1)
  179. b = Int((9 * Rnd) + 1)
  180. If a = b Then GoTo gb3
  181. res = a * b
  182. End If
  183. If oper = 4 Then
  184. sym = Chr(247)
  185. a = Int((9 * Rnd) + 1)
  186. b = Int((9 * Rnd) + 1)
  187. If a = b Then GoTo gb4
  188. res = a / b
  189. If a / b <> res Then GoTo gb2
  190. End If
  191. c = 1
  192. End If
  193. ForeColor = black
  194. FillStyle = 0
  195. x1 = 35 + buc * 220
  196. y1 = 30 * (ctr - 1)
  197. x2 = 35 + buc * 215 + 170
  198. y2 = 30 * (ctr - 1) + 30
  199. x3 = 35 + buc * 220
  200. y3 = 30 * ctr
  201. Line (x1, y1)-(x2, y2), , B
  202. ForeColor = white
  203. FillStyle = 1
  204. If y3 < lim(buc + 1) * 30 Then
  205. PSet (x3, y3), black
  206. Print a; sym; b; "="
  207. PSet (x3, y3), black
  208. ForeColor = red
  209. Print a; sym; b; "="; res
  210. ForeColor = white
  211. End If
  212. ctr = ctr + 1
  213. If ctr > lim(buc + 1) Then
  214. ctr = 3
  215. c = 0
  216. lim(buc + 1) = lim(buc + 1) - 1
  217. check(buc + 1) = check(buc + 1) + 1
  218. buf = ""
  219. End If
  220. End Sub
  221.